Ext.onReady(function(){
    var Docs = {};    
    Docs.classData={    
        "id":"root",    
        "text":"指标",    
        "singleClickExpand":true,    
        "expanded":true,    
        "leaf":false
    };   

  //树
    var treeBL = new Ext.tree.TreePanel({
    	id:'treeBL',
    	height:608,
		autoScroll: true,
		collapsible: true,
		enableDrag:true,
		enableDD: true,//可拖拽
		ddGroup: 'customDDGroup',
		split: true,
		margins: '2 2 2 2',
		useArrows:true,
		rootVisible : false,
    	loader: new Ext.tree.TreeLoader({    
            preloadChildren: true,//若为true，则loader在节点第一次访问时加载"children"的属性    
            clearOnLoad: false//（可选）默认为true。在读取数据前移除已存在的节点    
        }),    
    	root: Docs.classData,
    	listeners:{
			click:function(node){
				var o = new Object();
				if(node.attributes.comColumn=='true'){
					o.text=node.attributes.table;
				}
				else{
					o.text='sum($'+node.attributes.table+'.'+node.attributes.column+')';
				}
        		addquery(o,'selColumnSql_');
			}
    	}
    });
    
		  //树
		    var treeBL_modify_ = new Ext.tree.TreePanel({
		    	id:'treeBL_modify_',
		    	height:608,
				autoScroll: true,
				collapsible: true,
				enableDrag:true,
				enableDD: true,//可拖拽
				ddGroup: 'customDDGroup',
				split: true,
				margins: '2 2 2 2',
				useArrows:true,
				rootVisible : false,
		    	loader: new Ext.tree.TreeLoader({    
	                preloadChildren: true,//若为true，则loader在节点第一次访问时加载"children"的属性    
	                clearOnLoad: false//（可选）默认为true。在读取数据前移除已存在的节点    
	            }),    
		    	root: Docs.classData,
		    	listeners:{
					click:function(node){
						var o = new Object();
						if(node.attributes.comColumn=='true'){
							o.text=node.attributes.table;
						}
						else{
							o.text='sum($'+node.attributes.table+'.'+node.attributes.column+')';
						}
			    		addquery(o,'selColumnSql_modify_');
					}
		    	}
		    });
		    
	    
    ///标签页
	var tabs_modify_ = new Ext.TabPanel({
		resizeTabs:true, // tab宽度自动调整
		tabWidth:70,		//tab初始宽度
		width:all_width * 20 / 100,
		enableTabScroll:true,//tab超出范围出现横向滚动条
		frame:true,
		activeTab:0,
		region: 'west',
		defaults: {bodyStyle:'background:#dfe8f6;border: 1px solid #dfe8f6'}, 
		items:[{
			id:'tab1_1_modify',
			title:'指标分类',
			listeners:{//by mengqingyu modify 显示普通模式tab
				activate:function(e){Ext.getCmp('tab_normal_modify').unhideTabStripItem(0)}
			},	
			layout:'fit',
			items:[{
				width:all_width * 20 / 100,
				autoScroll: true,
				collapsible: true,
				id: 'tree-panel-measures-modify',
				enableDrag:true,
				ddGroup: 'customDDGroup',
				split: true,
				xtype: 'treepanel',
				margins: '2 2 2 2',
				useArrows:true,
				rootVisible : false,
				root: {text: '指标分类',draggable: false,id: '-1',isRoot:true},
				loader: new Ext.tree.TreeLoader({ 
						dataUrl: getRootPath()+'/detailReport.report?decorate=no',
						listeners:{beforeload:function(treeLoader, node){
							if(node.attributes.isRoot==true){
								this.baseParams.method = "getRoot";
							}else{
								this.baseParams.method = "getChilds";
							}
							this.baseParams.xmlId = xml_id_;
							this.baseParams.tableName = node.attributes.table;
							this.baseParams.pid = node.attributes.val;
							this.baseParams.level = node.attributes.level;
							this.baseParams.dir = node.attributes.d;
							this.baseParams.time = node.attributes.time;
							this.baseParams.currentTime = Ext.getCmp('currentTime').getRawValue();
					   }}
				}),
				listeners:{
					beforeappend:function(tree,parent,node){
	         		//判断是否是报告期
						//if(node.attributes.isTime=='true'){
							//return false;	
						//}else{
							//return true;
						//}
	         	}
				}
			}]	//添加table
		},{
			id:'tab1_2_modify',
			title:'指标',
			items:[treeBL_modify_],
			listeners:{//by mengqingyu modify 隐藏普通模式tab
				activate:function(e){Ext.getCmp('tab_normal_modify').hideTabStripItem(0),Ext.getCmp('tab_normal_modify').setActiveTab(1)}
			}
		}]
	});
	//标签页添加
	var tabs = new Ext.TabPanel({
		resizeTabs:true, // tab宽度自动调整
		tabWidth:70,		//tab初始宽度
		width:all_width * 20 / 100,
		enableTabScroll:true,//tab超出范围出现横向滚动条
		frame:true,
		activeTab:0,
		region: 'west',
		defaults: {bodyStyle:'background:#dfe8f6;border: 1px solid #dfe8f6'}, 
		items:[{
			id:'tab1_1',
			title:'指标分类',
			listeners:{//by mengqingyu modify 显示普通模式tab
				activate:function(e){Ext.getCmp('tab_normal').unhideTabStripItem(0)}
			},
			layout:'fit',
			items:[{
				id: 'tree-panel-measures',
				autoScroll: true,
				collapsible: true,
				enableDrag:true,
				ddGroup: 'customDDGroup',
				split: true,
				margins: '2 2 2 2',
				useArrows:true,
				rootVisible : false,
				xtype: 'treepanel',
				root: {text: '指标分类',draggable: false,id: '-1',isRoot:true},
				loader: new Ext.tree.TreeLoader({ 
						dataUrl: getRootPath()+'/detailReport.report?decorate=no',
						listeners:{beforeload:function(treeLoader, node){
							if(node.attributes.isRoot==true){
								this.baseParams.method = "getRoot";
							}else{
								this.baseParams.method = "getChilds";
							}
							this.baseParams.xmlId = xml_id_;
							this.baseParams.tableName = node.attributes.table;
							this.baseParams.pid = node.attributes.val;
							this.baseParams.level = node.attributes.level;
							this.baseParams.dir = node.attributes.d;
							this.baseParams.time = node.attributes.time;
							this.baseParams.currentTime = Ext.getCmp('currentTime').getRawValue();
							
					   }}
				}),
				listeners:{
					beforeappend:function(tree,parent,node){
	         		//判断是否是报告期
						//if(node.attributes.isTime=='true'){
							//return false;	
						//}else{
							//return true;
						//}
	         	}
				}
			}]	//添加table
		},{
			id:'tab1_2',
			title:'指标',
			items:[Ext.getCmp('treeBL')],
			listeners:{//by mengqingyu modify 隐藏普通模式tab
				activate:function(e){Ext.getCmp('tab_normal').hideTabStripItem(0),Ext.getCmp('tab_normal').setActiveTab(1)}
			}	
		}]
	});
	//by mengqingyu modify end	
		//添加自定义指标
		var advancedColumnWindow_ = new Ext.Window({
			width:670,	
	    	height: 500,
	    	layout: "border",
	    	title:'添加自定义指标',
	    	modal: true,
	    	border:false,
	    	id: "customH_win_",
	    	closeAction: 'hide',
	    	listeners:{show:function(a){
				var customDropTarget1 = new Ext.dd.DropTarget(Ext.getCmp('selColumnColumn_simple_div_').getEl().dom, {
					ddGroup: 'customDDGroup',
					copy: false,
					notifyDrop: function(ddSource, e, data){
						node = ddSource.dragData.node;
						var a=Ext.getCmp('selColumnColumn_simple_');
						a.setValue(node.text);
						a.code=node.attributes.table+'.'+node.attributes.column;
						return(true);
				}
			}); 	
				var customDropTarget2 = new Ext.dd.DropTarget(Ext.getCmp('selColumnCondition_simple_div_').getEl().dom, {
					ddGroup: 'customDDGroup',
					copy: false,
					notifyDrop: function(ddSource, e, data){
					node = ddSource.dragData.node;
					var a=Ext.getCmp('selColumnCondition_simple_');
					a.setValue(a.getValue()+'$'+node.attributes.table+'.'+node.attributes.column);
					return(true);
				}
			});
			}},
		    items: [tabs
		        ,{
		        	region:'center',
		        	width:320,
		        	height: 500,
		        	margins: '2 2 0 2',
		        	items:new Ext.TabPanel({
		        		id:'tab_normal',
		        		activeTab: 0,
		        		items:[{
		        			title:'普通模式',
		        			style:'padding:15px',
		        			height: 450,
		        			buttons:[{
		        				text:'保存',
		        				handler:function(){
				                   	 if(!Ext.getCmp('selColumnName_simple_').validate())
				                	 {
				                		return;
				                	 }
				                	 if(!Ext.getCmp('selColumnColumn_simple_').validate())
									 {
										return;
									 }
									 var express = '';
									 if(Ext.getCmp('selColumnCondition_simple_').getValue().trim()==''){//无条件
										 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'($'+Ext.getCmp('selColumnColumn_simple_').code+')';
									 }else{
										 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'(case when '+Ext.getCmp('selColumnCondition_simple_').getValue().trim()+' then $'+Ext.getCmp('selColumnColumn_simple_').code+' end)';
									 }
									 var param = {column:Ext.getCmp('selColumnColumn_simple_').code,isSimpleModel:'true',name:Ext.getCmp('selColumnName_simple_').getValue(),code:express,selColumnColumnName:Ext.getCmp('selColumnColumn_simple_').getValue(),selColumnColumnMethod:Ext.getCmp('selColumnMethod_simple_').getValue(),selColumnConditio:Ext.getCmp('selColumnCondition_simple_').getValue().trim()};
									 var grid = Ext.getCmp('measures_grid');
									 var store = grid.getStore();
									 store.add(new Ext.data.Record(param));
									 Ext.getCmp('customH_win_').hide();
		        				}
		        			},{
		        				text:'保存并继续添加',
		        				handler:function(){
			                   	 if(!Ext.getCmp('selColumnName_simple_').validate())
			                	 {
			                		return;
			                	 }
			                	 if(!Ext.getCmp('selColumnColumn_simple_').validate())
								 {
									return;
								 }
								 var express = '';
								 if(Ext.getCmp('selColumnCondition_simple_').getValue().trim()==''){//无条件
									 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'($'+Ext.getCmp('selColumnColumn_simple_').code+')';
								 }else{
									 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'(case when '+Ext.getCmp('selColumnCondition_simple_').getValue().trim()+' then $'+Ext.getCmp('selColumnColumn_simple_').code+' end)';
								 }
								 var param = {column:Ext.getCmp('selColumnColumn_simple_').code,isSimpleModel:'true',name:Ext.getCmp('selColumnName_simple_').getValue(),code:express,selColumnColumnName:Ext.getCmp('selColumnColumn_simple_').getValue(),selColumnColumnMethod:Ext.getCmp('selColumnMethod_simple_').getValue(),selColumnCondition:Ext.getCmp('selColumnCondition_simple_').getValue().trim()};
								 var grid = Ext.getCmp('measures_grid');
								 var store = grid.getStore();
								 store.add(new Ext.data.Record(param));
	        				}
		        			}],
		        			buttonAlign:'right',
		        			items:[{
		        				xtype:'fieldset',
		        				collapsible: true,
		        				title: '自定义指标名称',
		        				style:'padding:15px',
		        				height: 80,
		        				defaults:{labelWidth:60,layout:'form',border:false},
		        				items:[{
			        				items:[{
			        					id:'selColumnName_simple_',
				        				xtype:'textfield',
				        				fieldLabel:'指标名称',
				        				border:true,
				        				allowBlank:false,
				        				blankText:'指标名称不能为空',
				        				width:240
				        			}]
			        			}]
		        			},{
		        				xtype:'fieldset',
		        				title: '自定义指标配置',
		        				style:'padding:15px',
		        				height: 150,
		        	            collapsible: true,
		        				layout:'table',
			        			frame:true,
			        			layoutConfig: {columns:3},
			        			defaults:{labelWidth:60,layout:'form',border:false},
			        			items:[{
			        				id:'selColumnColumn_simple_div_',
			        				items:[{
			        					id:'selColumnColumn_simple_',
			        					xtype:'textfield',
			        					fieldLabel:'汇总列',
			        					blankText:'汇总列不能为空',
			        					allowBlank:false,
			        					editable:false,
			        					width:100
			        				}]
			        			},{
			        				width:10,
		        					border:false
			        			},{
			        				items:[{
			        					id:'selColumnMethod_simple_',
			        					xtype:'combo',
			        					fieldLabel:'汇总方式',
			        					store:new Ext.data.SimpleStore({
			        						fields: ['name', 'valtext'],
			        						data : [['求和','sum'],['平均值', 'avg'],['总数', 'count'],['最大值', 'max'],['最小值', 'min']]
			        					}),
			        					displayField:'name',
			        					mode: 'local',
			        					value:'sum',
			        					editable:false,
			        					valueField: "valtext",
			        					triggerAction: "all",
			        					width:60
			        				}]
			        			},{
			        				colspan:3,
			        				height:20,
		        					border:false
			        			},{
			        				id:'selColumnCondition_simple_div_',
			        				items:[{
			        					id:'selColumnCondition_simple_',
			        					xtype:'textfield',
			        					fieldLabel:'汇总条件',
			        					width:240
			        				}],
			        				colspan:3
			        			}]
		        			}]
		        		},
		        		{
		        		title:'高级模式',
		        		layout: 'table',
		        		border:false,
		        		height: 450,
		        		bodyStyle:'padding:10px 10px 10px 20px',
		        		layoutConfig: {columns:5},
		        		defaults:{frame:false,style:'padding:2px',minWidth: '60',style:{marginBottom: '10px'}},
		        		items:[
        		         {
        		    	    id:'selColumnName_',
        		    	    xtype:'textfield',
        		    	    width  : 350,
        		    	    colspan:5,
        		    	    emptyText:'请输入自定义列名称',
        		    	    allowBlank:false,
        		    	    blankText:'自定义列名称不能为空'
        		         },
		        		 {
				            xtype: "textarea",
				            id: "selColumnSql_",
				            width  : 350,
				            height : 140,
				            enableKeyEvents: true,
				            hideLabel:true,
				            allowBlank:false,
				            blankText:'自定义列表达式不能为空',
				            colspan:5,
				            style: {
		        			 	marginBottom: '10px',
				                imeMode:'disabled'		//屏蔽输入法
				            },
				            listeners:
			            	{
			            		'render':function(e)
			            		{
			            			//屏蔽粘贴和鼠标右键
			            			//Ext.get('selColumnSql_').dom.oncontextmenu = function(e){return false;};
			            			//Ext.get('selColumnSql_').dom.onpaste = function(e){return false;};
			            		}
			            		,'keypress':function(e)
			            		{//屏蔽键盘按键
									//event.keyCode = 0;
									//event.returnvalue = false;
			            		}
			            		
			            	}
				        }		        		 
		        		 ,{
					        	xtype: "button",
					        	text: "sum",
			                    handler: function(){
			                    		//by mengqingyu modify 指标不参与聚合函数计算
			                    		var node;
			                    		if(tabs.getActiveTab().getId()=='tab1_1'){
			                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
			                    		}
			                    		else{
			                    			alert("请选择指标分类!");
			                    			return;
			                    		}
			                    		if(node != null){
				                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
			                    		}else{
			                    			alert("请选择指标!");
			                    		}
			                    }
			                }
			                ,{
					        	xtype: "button",
			                    text: "avg",
			                    handler: function(){
			                    		var node;
			                    		if(tabs.getActiveTab().getId()=='tab1_1'){
			                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
			                    		}
			                    		else{
			                    			alert("请选择指标分类!");
			                    			return;
			                    		}
			                    		if(node != null){
				                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
			                    		}else{
			                    			alert("请选择指标!");
			                    		}
			                    }
			                }
			                ,{
					        	xtype: "button",
			                    text: "count",
			                    handler: function(){
			                    		var node;
			                    		if(tabs.getActiveTab().getId()=='tab1_1'){
			                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
			                    		}
			                    		else{
			                    			alert("请选择指标分类!");
			                    			return;
			                    		}
			                    		if(node != null){
				                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
			                    		}else{
			                    			alert("请选择指标!");
			                    		}
			                    }
			                }
			                ,{
					        	xtype: "button",
			                    text: "max",
			                    handler: function(){
	                    				var node;
			                    		if(tabs.getActiveTab().getId()=='tab1_1'){
			                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
			                    		}
			                    		else{
			                    			alert("请选择指标分类!");
			                    			return;
			                    		}
		                    		if(node != null){
			                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
			                    }
			                }
			                ,{
					        	xtype: "button",
			                    text: "min",
			                    handler: function(){
		                    		var node;
		                    		if(tabs.getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
		                    		if(node != null){
			                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
			                    }
			                }
		        		 ,{
					        	xtype: "button",
			                    text: "c-sum",
			                    handler: function(){
		                    		var node;
		                    		if(tabs.getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
		                    		if(node != null){
		                    			this.text="sum";
		                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
			                    }
			             }
				        , {
				        	xtype: "button",
		                    text: "7",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
				        }
				        , {
				        	xtype: "button",
		                    text: "8",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: "9",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: " + ",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		        		,{
					        	xtype: "button",
			                    text: "c-avg",
			                    handler: function(){
		                    		var node;
		                    		if(tabs.getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
		                    		if(node != null){
		                    			this.text="avg";
		                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
			                    }
			            }
		                , {
				        	xtype: "button",
		                    text: "4",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
				        }
		                ,{
				        	xtype: "button",
		                    text: "5",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: "6",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: " - ",
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		        		,{
				        	xtype: "button",
		                    text: "c-count",
		                    handler: function(){
	                    		var node;
	                    		if(tabs.getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
	                    			this.text="count";
	                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		        		}
		                ,{
				        	xtype: "button",
		                    text: "1",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: "2",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: "3",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: " * ",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		        		,{
				        	xtype: "button",
		                    text: "c-max",
		                    handler: function(){
	                    		var node;
	                    		if(tabs.getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
	                    			this.text="count";
	                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		        		}
		                ,{
				        	xtype: "button",
		                    text: "0",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: ".",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: " % ",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: " / ",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		        		,{
				        	xtype: "button",
		                    text: "c-min",
		                    handler: function(){
	                    		var node;
	                    		if(tabs.getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
	                    			this.text="min";
	                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		        		}
		                ,{
				        	xtype: "button",
		                    text: " ( ",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: " ) ",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: "\'",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		                ,{
				        	xtype: "button",
		                    text: ",",
		                    style:
		                    {
		                    	marginBottom: '5px'
		                    },
		                    handler: function(){addquery(this,'selColumnSql_');}
		                }
		        		,{
				        	xtype: "button",
		                    text: "select",
		                    handler: function(){
	                    		var node;
	                    		if(tabs.getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
	                    			this.text='$'+node.attributes.table+"."+node.attributes.column;
	                    			addquery(this,'selColumnSql_');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		        		}
		                ,{
				        	xtype: "button",
		                    text: " 清除 ",
		                    handler: function(){
		                    		Ext.getCmp('selColumnSql_').setValue() == "";
										}
		                }
		                ,{
				        	xtype: "button",
		                    text: " 保存 ",
		                    handler: function(){
			                	 if(!Ext.getCmp('selColumnName_').validate())
			                	 {
			                		return;
			                	 }
			                	 if(!Ext.getCmp('selColumnSql_').validate())
								 {
									return;
								 }
								 var param = {table:"("+Ext.getCmp('selColumnSql_').getValue()+")",isAdvanceModel:'true',name:Ext.getCmp('selColumnName_').getValue(),code:"("+Ext.getCmp('selColumnSql_').getValue()+")"};
								 var grid = Ext.getCmp('measures_grid');
								 var store = grid.getStore();
								 store.add(new Ext.data.Record(param));
								 Ext.getCmp('customH_win_').hide();
		                    }
		                }
		                ,{
				        	xtype: "button",
		                    text: " 保存并继续添加 ",
		                    colspan:2,
		                    minWidth:130,
		                    handler: function(){
			                	 if(!Ext.getCmp('selColumnName_').validate())
			                	 {
			                		return;
			                	 }
			                	 if(!Ext.getCmp('selColumnSql_').validate())
								 {
									return;
								 }
								 var param = {table:"("+Ext.getCmp('selColumnSql_').getValue()+")",isAdvanceModel:'true',name:Ext.getCmp('selColumnName_').getValue(),code:"("+Ext.getCmp('selColumnSql_').getValue()+")"};
								 var grid = Ext.getCmp('measures_grid');
								 var store = grid.getStore();
								 store.add(new Ext.data.Record(param));
		                    }
		                }
		        		]
		        	}]})
		        }
		   		]
		 	});//Ext.Window
		//修改tab
		var modify_tab = new Ext.TabPanel({
    		activeTab: 0,
    		id:'tab_normal_modify',
    		items:[{
    			title:'普通模式',
    			style:'padding:15px',
    			height: 450,
    			buttons:[{
    				text:'修改',
    				handler:function(){
	                   	 if(!Ext.getCmp('selColumnName_simple_modify_').validate())
	                	 {
	                		return;
	                	 }
	                	 if(!Ext.getCmp('selColumnColumn_simple_modify_').validate())
						 {
							return;
						 }
						 var express = '';
						 if(Ext.getCmp('selColumnCondition_simple_modify_').getValue().trim()==''){//无条件
							 express=Ext.getCmp('selColumnMethod_simple_modify_').getValue()+'($'+Ext.getCmp('selColumnColumn_simple_modify_').code+')';
						 }else{
							 express=Ext.getCmp('selColumnMethod_simple_modify_').getValue()+'(case when '+Ext.getCmp('selColumnCondition_simple_modify_').getValue().trim()+' then $'+Ext.getCmp('selColumnColumn_simple_modify_').code+' end)';
						 }
						 var record = Ext.getCmp('customH_win_modify_').evObject;
						 record.data.name = Ext.getCmp('selColumnName_simple_modify_').getValue();
						 record.data.selColumnColumnName = Ext.getCmp('selColumnColumn_simple_modify_').getValue();
						 record.data.selColumnColumnMethod = Ext.getCmp('selColumnMethod_simple_modify_').getValue();
						 record.data.selColumnCondition = Ext.getCmp('selColumnCondition_simple_modify_').getValue();
						 record.data.code = express;
						 record.data.column = Ext.getCmp('selColumnColumn_simple_modify_').code;
						 record.data.isSimpleModel = 'true';
						 record.commit();
						 Ext.getCmp('customH_win_modify_').hide();
    				}
    			}],
    			buttonAlign:'right',
    			items:[{
    				xtype:'fieldset',
    				collapsible: true,
    				title: '自定义指标名称',
    				style:'padding:15px',
    				height: 80,
    				defaults:{labelWidth:60,layout:'form',border:false},
    				items:[{
        				items:[{
        					id:'selColumnName_simple_modify_',
	        				xtype:'textfield',
	        				fieldLabel:'指标名称',
	        				border:true,
	        				allowBlank:false,
	        				blankText:'指标名称不能为空',
	        				width:240
	        			}]
        			}]
    			},{
    				xtype:'fieldset',
    				title: '自定义指标配置',
    				style:'padding:15px',
    				height: 150,
    	            collapsible: true,
    				layout:'table',
        			frame:true,
        			layoutConfig: {columns:3},
        			defaults:{labelWidth:60,layout:'form',border:false},
        			items:[{
        				id:'selColumnColumn_simple_div_modify_',
        				items:[{
        					id:'selColumnColumn_simple_modify_',
        					xtype:'textfield',
        					fieldLabel:'汇总列',
        					blankText:'汇总列不能为空',
        					allowBlank:false,
        					editable:false,
        					width:100
        				}]
        			},{
        				width:10,
    					border:false
        			},{
        				items:[{
        					id:'selColumnMethod_simple_modify_',
        					xtype:'combo',
        					fieldLabel:'汇总方式',
        					store:new Ext.data.SimpleStore({
        						fields: ['name', 'valtext'],
        						data : [['求和','sum'],['平均值', 'avg'],['总数', 'count'],['最大值', 'max'],['最小值', 'min']]
        					}),
        					displayField:'name',
        					mode: 'local',
        					value:'sum',
        					editable:false,
        					valueField: "valtext",
        					triggerAction: "all",
        					width:60
        				}]
        			},{
        				colspan:3,
        				height:20,
    					border:false
        			},{
        				id:'selColumnCondition_simple_div_modify_',
        				items:[{
        					id:'selColumnCondition_simple_modify_',
        					xtype:'textfield',
        					fieldLabel:'汇总条件',
        					width:240
        				}],
        				colspan:3
        			}]
    			}]
    		},{
    			title:'高级模式',
        		layout: 'table',
        		height: 450,
        		border:false,
        		bodyStyle:'padding:10px 10px 10px 20px',
        		layoutConfig: {columns:5},
        		defaults:{frame:false,style:'padding:2px',minWidth: '60',style:{marginBottom: '10px'}},
        		items:[
		         {
 		    	    id:'selColumnName_modify_',
 		    	    xtype:'textfield',
 		    	    width  : 350,
 		    	    colspan:5,
 		    	    emptyText:'请输入自定义列名称',
 		    	    allowBlank:false,
 		    	    blankText:'自定义列名称不能为空'
 		         },
	        		 {
			            xtype: "textarea",
			            id: "selColumnSql_modify_",
			            width  : 350,
			            height : 140,
			            enableKeyEvents: true,
			            hideLabel:true,
			            allowBlank:false,
			            blankText:'自定义列表达式不能为空',
			            colspan:5,
		            style: {
        			 	marginBottom: '10px',
		                imeMode:'disabled'		//屏蔽输入法
		            },
		            listeners:
	            	{
	            		'render':function(e)
	            		{
	            			//屏蔽粘贴和鼠标右键
	            			//Ext.get('selColumnSql_').dom.oncontextmenu = function(e){return false;};
	            			//Ext.get('selColumnSql_').dom.onpaste = function(e){return false;};
	            		}
	            		,'keypress':function(e)
	            		{//屏蔽键盘按键
							//event.keyCode = 0;
							//event.returnvalue = false;
	            		}
	            		
	            	}
		        }		        		 
        		 ,{
			        	xtype: "button",
	                    text: "sum",
	                    handler: function(){
	                    		//by mengqingyu modify 指标不参与聚合函数计算
			             		var node;
			            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
			            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
			            		}
			            		else{
			            			alert("请选择指标分类!");
			            			return;
			            		}
	                    		if(node != null){
		                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                    }
	                }
	                ,{
			        	xtype: "button",
	                    text: "avg",
	                    handler: function(){
			             		var node;
			            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
			            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
			            		}
			            		else{
			            			alert("请选择指标分类!");
			            			return;
			            		}
	                    		if(node != null){
		                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                    }
	                }
	                ,{
			        	xtype: "button",
	                    text: "count",
			                    handler: function(){
			             		var node;
			            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
			            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
			            		}
			            		else{
			            			alert("请选择指标分类!");
			            			return;
			            		}
	                    		if(node != null){
		                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                    }
	                }
	                ,{
			        	xtype: "button",
	                    text: "max",
	                    handler: function(){
		             		var node;
		            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
		            		}
		            		else{
		            			alert("请选择指标分类!");
		            			return;
		            		}
                    		if(node != null){
	                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	                }
	                ,{
			        	xtype: "button",
	                    text: "min",
	                    handler: function(){
		             		var node;
		            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
		            		}
		            		else{
		            			alert("请选择指标分类!");
		            			return;
		            		}
                    		if(node != null){
	                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	                }
        		 ,{
			        	xtype: "button",
	                    text: "c-sum",
	                    handler: function(){
		             		var node;
		            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
		            		}
		            		else{
		            			alert("请选择指标分类!");
		            			return;
		            		}
                    		if(node != null){
                    			this.text="sum";
                    			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	             }
		        , {
		        	xtype: "button",
                    text: "7",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
		        }
		        , {
		        	xtype: "button",
                    text: "8",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: "9",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: " + ",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
        		,{
			        	xtype: "button",
	                    text: "c-avg",
	                    handler: function(){
		             		var node;
		            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
		            		}
		            		else{
		            			alert("请选择指标分类!");
		            			return;
		            		}
                    		if(node != null){
                    			this.text="avg";
                    			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	            }
                , {
		        	xtype: "button",
                    text: "4",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
		        }
                ,{
		        	xtype: "button",
                    text: "5",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: "6",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: " - ",
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
        		,{
		        	xtype: "button",
                    text: "c-count",
                    handler: function(){
	             		var node;
	            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	            		}
	            		else{
	            			alert("请选择指标分类!");
	            			return;
	            		}
                		if(node != null){
                			this.text="count";
                			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                		}else{
                			alert("请选择指标!");
                		}
                    }
        		}
                ,{
		        	xtype: "button",
                    text: "1",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: "2",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: "3",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: " * ",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
        		,{
		        	xtype: "button",
                    text: "c-max",
                    handler: function(){
	             		var node;
	            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	            		}
	            		else{
	            			alert("请选择指标分类!");
	            			return;
	            		}
                		if(node != null){
                			this.text="count";
                			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                		}else{
                			alert("请选择指标!");
                		}
                    }
        		}
                ,{
		        	xtype: "button",
                    text: "0",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: ".",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: " % ",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: " / ",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
        		,{
		        	xtype: "button",
                    text: "c-min",
                    handler: function(){
	             		var node;
	            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	            		}
	            		else{
	            			alert("请选择指标分类!");
	            			return;
	            		}
                		if(node != null){
                			this.text="min";
                			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                		}else{
                			alert("请选择指标!");
                		}
                    }
        		}
                ,{
		        	xtype: "button",
                    text: " ( ",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: " ) ",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: "\'",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
                ,{
		        	xtype: "button",
                    text: ",",
                    style:
                    {
                    	marginBottom: '5px'
                    },
                    handler: function(){addquery(this,'selColumnSql_modify_');}
                }
        		,{
		        	xtype: "button",
                    text: "select",
                    handler: function(){
	             		var node;
	            		if(tabs_modify_.getActiveTab().getId()=='tab1_1_modify'){
	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	            		}
	            		else{
	            			alert("请选择指标分类!");
	            			return;
	            		}
                		if(node != null){
                			this.text='$'+node.attributes.table+"."+node.attributes.column;
                			addquery(this,'selColumnSql_modify_');
                		}else{
                			alert("请选择指标!");
                		}
                    }
        		}
                ,{
		        	xtype: "button",
                    text: " 清除 ",
                    handler: function(){
                    		Ext.getCmp('selColumnSql_modify_').setValue() == "";
								}
                }
                ,{
		        	xtype: "button",
                    text: " 修改 ",
                    handler: function(){
	                	 if(!Ext.getCmp('selColumnName_modify_').validate())
	                	 {
	                		return;
	                	 }
	                	 if(!Ext.getCmp('selColumnSql_modify_').validate())
						 {
							return;
						 }
	                	 var record = Ext.getCmp('customH_win_modify_').evObject;
						 record.data.name = Ext.getCmp('selColumnName_modify_').getValue();
						 record.data.code = "("+Ext.getCmp('selColumnSql_modify_').getValue()+")";
						 record.data.isAdvanceModel = 'true';
						 record.commit();
						 Ext.getCmp('customH_win_modify_').hide();
                    }
                }
        		]
    	}]});
		//by mengqingyu add begin
		var advancedColumnWindow_modify_ = new Ext.Window({	
			width:670,	
	    	height: 500,
	    	layout: "border",
	    	title:'修改自定义指标',
	    	evObject:null,
	    	modal: true,
	    	border:false,
	    	id: "customH_win_modify_",
	    	closeAction: 'hide',
	    	listeners:{show:function(a){
				var customDropTarget1 = new Ext.dd.DropTarget(Ext.getCmp('selColumnColumn_simple_div_modify_').getEl().dom, {
					ddGroup: 'customDDGroup',
					copy: false,
					notifyDrop: function(ddSource, e, data){
						node = ddSource.dragData.node;
						var a=Ext.getCmp('selColumnColumn_simple_modify_');
						a.setValue(node.text);
						a.code=node.attributes.table+'.'+node.attributes.column;
						return(true);
				}
				}); 	
					var customDropTarget2 = new Ext.dd.DropTarget(Ext.getCmp('selColumnCondition_simple_div_modify_').getEl().dom, {
						ddGroup: 'customDDGroup',
						copy: false,
						notifyDrop: function(ddSource, e, data){
						node = ddSource.dragData.node;
						var a=Ext.getCmp('selColumnCondition_simple_modify_');
						a.setValue(a.getValue()+ '$' +node.attributes.table+'.'+node.attributes.column);
						return(true);
					}
				});
			}},
		    items: [tabs_modify_
		        ,{
		        	region:'center',
		        	width:320,
		        	height: 500,
		        	margins: '2 2 0 2',
		        	items:modify_tab
		        }
		   		]
		 	});//Ext.Window
});
//添加自定义指标
function number(){
	return document.getElementById('droppableH').childNodes[0].childNodes.length;
}
function addCustomMeasureWin(){
	if(Ext.getCmp('customH_win_') == null)
	var advancedColumnWindow_ = new Ext.Window({	
		width:670,	
    	height: 500,
    	layout: "border",
    	title:'添加自定义指标',
    	modal: true,
    	border:false,
    	id: "customH_win_",
    	closeAction: 'hide',
    	listeners:{show:function(a){
			var customDropTarget1 = new Ext.dd.DropTarget(Ext.getCmp('selColumnColumn_simple_div_').getEl().dom, {
				ddGroup: 'customDDGroup',
				copy: false,
				notifyDrop: function(ddSource, e, data){
					node = ddSource.dragData.node;
					var a=Ext.getCmp('selColumnColumn_simple_');
					a.setValue(node.text);
					a.code=node.attributes.table+'.'+node.attributes.column;
					return(true);
			}
		}); 	
			var customDropTarget2 = new Ext.dd.DropTarget(Ext.getCmp('selColumnCondition_simple_div_').getEl().dom, {
				ddGroup: 'customDDGroup',
				copy: false,
				notifyDrop: function(ddSource, e, data){
				node = ddSource.dragData.node;
				var a=Ext.getCmp('selColumnCondition_simple_');
				a.setValue(a.getValue()+'$'+node.attributes.table+'.'+node.attributes.column);
				return(true);
			}
		});
		}},
	    items: [{
	    		id:'tabs',
		    	xtype:'tabpanel',
				resizeTabs:true, // tab宽度自动调整
				tabWidth:70,		//tab初始宽度
				width:all_width * 20 / 100,
				enableTabScroll:true,//tab超出范围出现横向滚动条
				frame:true,
				activeTab:0,
				region: 'west',
				defaults: {bodyStyle:'background:#dfe8f6;border: 1px solid #dfe8f6'}, 
				items:[{
					id:'tab1_1',
					title:'指标分类',
					listeners:{//by mengqingyu modify 显示普通模式tab
						activate:function(e){Ext.getCmp('tab_normal').unhideTabStripItem(0)}
					},
					layout:'fit',
					items:[{
						id: 'tree-panel-measures',
						autoScroll: true,
						collapsible: true,
						enableDrag:true,
						ddGroup: 'customDDGroup',
						split: true,
						margins: '2 2 2 2',
						useArrows:true,
						rootVisible : false,
						xtype: 'treepanel',
						root: {text: '指标分类',draggable: false,id: '-1',isRoot:true,expanded:true},
						loader: new Ext.tree.TreeLoader({ 
								dataUrl: getRootPath()+'/detailReport.report?decorate=no',
								listeners:{beforeload:function(treeLoader, node){
									if(node.attributes.isRoot==true){
										this.baseParams.method = "getRoot";
									}else{
										this.baseParams.method = "getChilds";
									}
									this.baseParams.xmlId = xml_id_;
									this.baseParams.tableName = node.attributes.table;
									this.baseParams.pid = node.attributes.val;
									this.baseParams.level = node.attributes.level;
									this.baseParams.dir = node.attributes.d;
									this.baseParams.time = node.attributes.time;
									this.baseParams.currentTime = Ext.getCmp('currentTime').getRawValue();
									
							   }}
						}),
						listeners:{
							beforeappend:function(tree,parent,node){
			         		//判断是否是报告期
								//if(node.attributes.isTime=='true'){
									//return false;	
								//}else{
									//return true;
								//}
			         	}
						}
					}]	//添加table
				},{
					id:'tab1_2',
					title:'指标',
					items:[Ext.getCmp('treeBL')],
					listeners:{//by mengqingyu modify 隐藏普通模式tab
						activate:function(e){Ext.getCmp('tab_normal').hideTabStripItem(0),Ext.getCmp('tab_normal').setActiveTab(1)}
					}	
				}]
		      }
	        ,{
	        	region:'center',
	        	width:320,
	        	height: 500,
	        	margins: '2 2 0 2',
	        	items:new Ext.TabPanel({
	        		id:'tab_normal',
	        		activeTab: 0,
	        		items:[{
	        			title:'普通模式',
	        			style:'padding:15px',
	        			height: 450,
	        			buttons:[{
	        				text:'保存',
	        				handler:function(){
			                   	 if(!Ext.getCmp('selColumnName_simple_').validate())
			                	 {
			                		return;
			                	 }
			                	 if(!Ext.getCmp('selColumnColumn_simple_').validate())
								 {
									return;
								 }
								 var express = '';
								 if(Ext.getCmp('selColumnCondition_simple_').getValue().trim()==''){//无条件
									 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'($'+Ext.getCmp('selColumnColumn_simple_').code+')';
								 }else{
									 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'(case when '+Ext.getCmp('selColumnCondition_simple_').getValue().trim()+' then $'+Ext.getCmp('selColumnColumn_simple_').code+' end)';
								 }			
								 jQuery("#droppableH").find('ul').append("<li id='"+'column'+number()+"' time='"+defaultDate+"' isSimpleModel='true' selColumnColumnCode='"+Ext.getCmp('selColumnColumn_simple_').code+"' selColumnColumnName='"+Ext.getCmp('selColumnColumn_simple_').getValue()+"' selColumnColumnMethod='"+Ext.getCmp('selColumnMethod_simple_').getValue()+"' selColumnCondition=\""+Ext.getCmp('selColumnCondition_simple_').getValue().trim()+"\" oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_simple_').getValue()+"' customH='true' express='"+express+"' class='h'>"+Ext.getCmp('selColumnName_simple_').getValue()+"</li>");
								 //by mengqingyu modify 保存指标内容
								 var param = {id:'column'+(number()-1),comColumn:'true',table:"("+express+")",time:defaultDate,isSimpleModel:'true',label:Ext.getCmp('selColumnName_simple_').getValue(),customH:'true',express:express,text:Ext.getCmp('selColumnName_simple_').getValue(),selColumnColumnCode:Ext.getCmp('selColumnColumn_simple_'),selColumnColumnName:Ext.getCmp('selColumnColumn_simple_').getValue(),selColumnColumnMethod:Ext.getCmp('selColumnMethod_simple_').getValue(),selColumnConditio:Ext.getCmp('selColumnCondition_simple_').getValue().trim()};
								 Ext.getCmp("treeBL").root.appendChild(new Ext.tree.TreeNode(param));
								 Ext.getCmp("treeBL_modify_").root.appendChild(new Ext.tree.TreeNode(param));
								 enable_move();
								 Ext.getCmp('customH_win_').close();
	        				}
	        			},{
	        				text:'保存并继续添加',
	        				handler:function(){
		                   	 if(!Ext.getCmp('selColumnName_simple_').validate())
		                	 {
		                		return;
		                	 }
		                	 if(!Ext.getCmp('selColumnColumn_simple_').validate())
							 {
								return;
							 }
							 var express = '';
							 if(Ext.getCmp('selColumnCondition_simple_').getValue().trim()==''){//无条件
								 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'($'+Ext.getCmp('selColumnColumn_simple_').code+')';
							 }else{
								 express=Ext.getCmp('selColumnMethod_simple_').getValue()+'(case when '+Ext.getCmp('selColumnCondition_simple_').getValue().trim()+' then $'+Ext.getCmp('selColumnColumn_simple_').code+' end)';
							 }
							 jQuery("#droppableH").find('ul').append("<li id='"+'column'+number()+"' time='"+defaultDate+"' isSimpleModel='true' selColumnColumnCode='"+Ext.getCmp('selColumnColumn_simple_').code+"' selColumnColumnName='"+Ext.getCmp('selColumnColumn_simple_').getValue()+"' selColumnColumnMethod='"+Ext.getCmp('selColumnMethod_simple_').getValue()+"' selColumnCondition=\""+Ext.getCmp('selColumnCondition_simple_').getValue().trim()+"\" oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_simple_').getValue()+"' customH='true' express='"+express+"' class='h'>"+Ext.getCmp('selColumnName_simple_').getValue()+"</li>");
							 var param = {id:'column'+(number()-1),comColumn:'true',table:"("+express+")",time:defaultDate,isSimpleModel:'true',label:Ext.getCmp('selColumnName_simple_').getValue(),customH:'true',express:express,text:Ext.getCmp('selColumnName_simple_').getValue(),selColumnColumnCode:Ext.getCmp('selColumnColumn_simple_'),selColumnColumnName:Ext.getCmp('selColumnColumn_simple_').getValue(),selColumnColumnMethod:Ext.getCmp('selColumnMethod_simple_').getValue(),selColumnConditio:Ext.getCmp('selColumnCondition_simple_').getValue().trim()};
							 Ext.getCmp("treeBL").root.appendChild(new Ext.tree.TreeNode(param));
							 Ext.getCmp("treeBL_modify_").root.appendChild(new Ext.tree.TreeNode(param));
							 enable_move();
        				}
	        			}],
	        			buttonAlign:'right',
	        			items:[{
	        				xtype:'fieldset',
	        				collapsible: true,
	        				title: '自定义指标名称',
	        				style:'padding:15px',
	        				height: 80,
	        				defaults:{labelWidth:60,layout:'form',border:false},
	        				items:[{
		        				items:[{
		        					id:'selColumnName_simple_',
			        				xtype:'textfield',
			        				fieldLabel:'指标名称',
			        				border:true,
			        				allowBlank:false,
			        				blankText:'指标名称不能为空',
			        				width:240
			        			}]
		        			}]
	        			},{
	        				xtype:'fieldset',
	        				title: '自定义指标配置',
	        				style:'padding:15px',
	        				height: 150,
	        	            collapsible: true,
	        				layout:'table',
		        			frame:true,
		        			layoutConfig: {columns:3},
		        			defaults:{labelWidth:60,layout:'form',border:false},
		        			items:[{
		        				id:'selColumnColumn_simple_div_',
		        				items:[{
		        					id:'selColumnColumn_simple_',
		        					xtype:'textfield',
		        					fieldLabel:'汇总列',
		        					blankText:'汇总列不能为空',
		        					allowBlank:false,
		        					editable:false,
		        					width:100
		        				}]
		        			},{
		        				width:10,
	        					border:false
		        			},{
		        				items:[{
		        					id:'selColumnMethod_simple_',
		        					xtype:'combo',
		        					fieldLabel:'汇总方式',
		        					store:new Ext.data.SimpleStore({
		        						fields: ['name', 'valtext'],
		        						data : [['求和','sum'],['平均值', 'avg'],['总数', 'count'],['最大值', 'max'],['最小值', 'min']]
		        					}),
		        					displayField:'name',
		        					mode: 'local',
		        					value:'sum',
		        					editable:false,
		        					valueField: "valtext",
		        					triggerAction: "all",
		        					width:60
		        				}]
		        			},{
		        				colspan:3,
		        				height:20,
	        					border:false
		        			},{
		        				id:'selColumnCondition_simple_div_',
		        				items:[{
		        					id:'selColumnCondition_simple_',
		        					xtype:'textfield',
		        					fieldLabel:'汇总条件',
		        					width:240
		        				}],
		        				colspan:3
		        			}]
	        			}]
	        		},
	        		{
	        		title:'高级模式',
	        		layout: 'table',
	        		border:false,
	        		height: 450,
	        		bodyStyle:'padding:10px 10px 10px 20px',
	        		layoutConfig: {columns:5},
	        		defaults:{frame:false,style:'padding:2px',minWidth: '60',style:{marginBottom: '10px'}},
	        		items:[
    		         {
    		    	    id:'selColumnName_',
    		    	    xtype:'textfield',
    		    	    width  : 350,
    		    	    colspan:5,
    		    	    emptyText:'请输入自定义列名称',
    		    	    allowBlank:false,
    		    	    blankText:'自定义列名称不能为空'
    		         },
	        		 {
			            xtype: "textarea",
			            id: "selColumnSql_",
			            width  : 350,
			            height : 140,
			            enableKeyEvents: true,
			            hideLabel:true,
			            allowBlank:false,
			            blankText:'自定义列表达式不能为空',
			            colspan:5,
			            style: {
	        			 	marginBottom: '10px',
			                imeMode:'disabled'		//屏蔽输入法
			            },
			            listeners:
		            	{
		            		'render':function(e)
		            		{
		            			//屏蔽粘贴和鼠标右键
		            			//Ext.get('selColumnSql_').dom.oncontextmenu = function(e){return false;};
		            			//Ext.get('selColumnSql_').dom.onpaste = function(e){return false;};
		            		}
		            		,'keypress':function(e)
		            		{//屏蔽键盘按键
								//event.keyCode = 0;
								//event.returnvalue = false;
		            		}
		            		
		            	}
			        }		        		 
	        		 ,{
				        	xtype: "button",
				        	text: "sum",
		                    handler: function(){
		                    		//by mengqingyu modify 指标不参与聚合函数计算
		                    		var node;
		                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
		                    		if(node != null){
			                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
		                    }
		                }
		                ,{
				        	xtype: "button",
		                    text: "avg",
		                    handler: function(){
		                    		var node;
		                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
		                    		if(node != null){
			                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
		                    }
		                }
		                ,{
				        	xtype: "button",
		                    text: "count",
		                    handler: function(){
		                    		var node;
		                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
		                    		if(node != null){
			                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
		                    		}else{
		                    			alert("请选择指标!");
		                    		}
		                    }
		                }
		                ,{
				        	xtype: "button",
		                    text: "max",
		                    handler: function(){
                    				var node;
		                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
		                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
		                    		}
		                    		else{
		                    			alert("请选择指标分类!");
		                    			return;
		                    		}
	                    		if(node != null){
		                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		                }
		                ,{
				        	xtype: "button",
		                    text: "min",
		                    handler: function(){
	                    		var node;
	                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
		                    		addquery(this,'selColumnSql_','$'+node.attributes.table+"."+node.attributes.column);
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		                }
	        		 ,{
				        	xtype: "button",
		                    text: "c-sum",
		                    handler: function(){
	                    		var node;
	                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
	                    			this.text="sum";
	                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		             }
			        , {
			        	xtype: "button",
	                    text: "7",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
			        }
			        , {
			        	xtype: "button",
	                    text: "8",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: "9",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: " + ",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	        		,{
				        	xtype: "button",
		                    text: "c-avg",
		                    handler: function(){
	                    		var node;
	                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
	                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
	                    		}
	                    		else{
	                    			alert("请选择指标分类!");
	                    			return;
	                    		}
	                    		if(node != null){
	                    			this.text="avg";
	                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
		                    }
		            }
	                , {
			        	xtype: "button",
	                    text: "4",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
			        }
	                ,{
			        	xtype: "button",
	                    text: "5",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: "6",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: " - ",
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	        		,{
			        	xtype: "button",
	                    text: "c-count",
	                    handler: function(){
                    		var node;
                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
                    		}
                    		else{
                    			alert("请选择指标分类!");
                    			return;
                    		}
                    		if(node != null){
                    			this.text="count";
                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	        		}
	                ,{
			        	xtype: "button",
	                    text: "1",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: "2",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: "3",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: " * ",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	        		,{
			        	xtype: "button",
	                    text: "c-max",
	                    handler: function(){
                    		var node;
                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
                    		}
                    		else{
                    			alert("请选择指标分类!");
                    			return;
                    		}
                    		if(node != null){
                    			this.text="count";
                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	        		}
	                ,{
			        	xtype: "button",
	                    text: "0",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: ".",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: " % ",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: " / ",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	        		,{
			        	xtype: "button",
	                    text: "c-min",
	                    handler: function(){
                    		var node;
                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
                    		}
                    		else{
                    			alert("请选择指标分类!");
                    			return;
                    		}
                    		if(node != null){
                    			this.text="min";
                    			addquery(this,'selColumnSql_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	        		}
	                ,{
			        	xtype: "button",
	                    text: " ( ",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: " ) ",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: "\'",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	                ,{
			        	xtype: "button",
	                    text: ",",
	                    style:
	                    {
	                    	marginBottom: '5px'
	                    },
	                    handler: function(){addquery(this,'selColumnSql_');}
	                }
	        		,{
			        	xtype: "button",
	                    text: "select",
	                    handler: function(){
                    		var node;
                    		if(Ext.getCmp('tabs').getActiveTab().getId()=='tab1_1'){
                    			node = Ext.getCmp('tree-panel-measures').getSelectionModel().getSelectedNode();
                    		}
                    		else{
                    			alert("请选择指标分类!");
                    			return;
                    		}
                    		if(node != null){
                    			this.text='$'+node.attributes.table+"."+node.attributes.column;
                    			addquery(this,'selColumnSql_');
                    		}else{
                    			alert("请选择指标!");
                    		}
	                    }
	        		}
	                ,{
			        	xtype: "button",
	                    text: " 清除 ",
	                    handler: function(){
	                    		Ext.getCmp('selColumnSql_').setValue() == "";
									}
	                }
	                ,{
			        	xtype: "button",
	                    text: " 保存 ",
	                    handler: function(){
		                	 if(!Ext.getCmp('selColumnName_').validate())
		                	 {
		                		return;
		                	 }
		                	 if(!Ext.getCmp('selColumnSql_').validate())
							 {
								return;
							 }
							 //by mengqingyu modify 保存指标内容
							 jQuery("#droppableH").find('ul').append("<li id='"+'column'+number()+"' time='"+defaultDate+"' isAdvanceModel='true' oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_').getValue()+"' customH='true' express='"+"("+Ext.getCmp('selColumnSql_').getValue()+")"+"' class='h'>"+Ext.getCmp('selColumnName_').getValue()+"</li>");
							 var param = {id:'column'+(number()-1),comColumn:'true',table:"("+Ext.getCmp('selColumnSql_').getValue()+")",time:defaultDate,isAdvanceModel:'true',label:Ext.getCmp('selColumnName_').getValue(),customH:'true',express:"("+Ext.getCmp('selColumnSql_').getValue()+")",text:Ext.getCmp('selColumnName_').getValue()};
							 Ext.getCmp("treeBL").root.appendChild(new Ext.tree.TreeNode(param));
							 Ext.getCmp("treeBL_modify_").root.appendChild(new Ext.tree.TreeNode(param));
							 enable_move();
							 Ext.getCmp('customH_win_').close();
	                    }
	                }
	                ,{
			        	xtype: "button",
	                    text: " 保存并继续添加 ",
	                    colspan:2,
	                    minWidth:130,
	                    handler: function(){
		                	 if(!Ext.getCmp('selColumnName_').validate())
		                	 {
		                		return;
		                	 }
		                	 if(!Ext.getCmp('selColumnSql_').validate())
							 {
								return;
							 }
							 //by mengqingyu modify 保存指标内容
		                	 jQuery("#droppableH").find('ul').append("<li id='"+'column'+number()+"' time='"+defaultDate+"' isAdvanceModel='true' oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_').getValue()+"' customH='true' express='"+"("+Ext.getCmp('selColumnSql_').getValue()+")"+"' class='h'>"+Ext.getCmp('selColumnName_').getValue()+"</li>");
							 var param = {id:'column'+number()-1,comColumn:'true',table:"("+Ext.getCmp('selColumnSql_').getValue()+")",time:defaultDate,isAdvanceModel:'true',label:Ext.getCmp('selColumnName_').getValue(),customH:'true',express:"("+Ext.getCmp('selColumnSql_').getValue()+")",text:Ext.getCmp('selColumnName_').getValue()};
							 Ext.getCmp("treeBL").root.appendChild(new Ext.tree.TreeNode(param));
							 Ext.getCmp("treeBL_modify_").root.appendChild(new Ext.tree.TreeNode(param));
							 enable_move();
	                    }
	                }
	        		]
	        	}]})
	        }
	   		]
 	});//Ext.Window
	Ext.getCmp('customH_win_').show();
}
//修改自定义指标
function updateCustomMeasureWin(ev){
	if(Ext.getCmp('customH_win_modify_') == null)
	var advancedColumnWindow_modify_ = new Ext.Window({	
		width:670,	
    	height: 500,
    	layout: "border",
    	title:'修改自定义指标',
    	evObject:null,
    	modal: true,
    	border:false,
    	id: "customH_win_modify_",
    	closeAction: 'hide',
    	listeners:{show:function(a){
			var customDropTarget1 = new Ext.dd.DropTarget(Ext.getCmp('selColumnColumn_simple_div_modify_').getEl().dom, {
				ddGroup: 'customDDGroup',
				copy: false,
				notifyDrop: function(ddSource, e, data){
					node = ddSource.dragData.node;
					var a=Ext.getCmp('selColumnColumn_simple_modify_');
					a.setValue(node.text);
					a.code=node.attributes.table+'.'+node.attributes.column;
					return(true);
			}
			}); 	
				var customDropTarget2 = new Ext.dd.DropTarget(Ext.getCmp('selColumnCondition_simple_div_modify_').getEl().dom, {
					ddGroup: 'customDDGroup',
					copy: false,
					notifyDrop: function(ddSource, e, data){
					node = ddSource.dragData.node;
					var a=Ext.getCmp('selColumnCondition_simple_modify_');
					a.setValue(a.getValue()+ '$' +node.attributes.table+'.'+node.attributes.column);
					return(true);
				}
			});
		}},
	    items: [{
	    	id:'tabs_modify_',
	    	xtype:'tabpanel',
			resizeTabs:true, // tab宽度自动调整
			tabWidth:70,		//tab初始宽度
			width:all_width * 20 / 100,
			enableTabScroll:true,//tab超出范围出现横向滚动条
			frame:true,
			activeTab:0,
			region: 'west',
			defaults: {bodyStyle:'background:#dfe8f6;border: 1px solid #dfe8f6'}, 
			items:[{
				id:'tab1_1_modify',
				title:'指标分类',
				listeners:{//by mengqingyu modify 显示普通模式tab
					activate:function(e){Ext.getCmp('tab_normal_modify').unhideTabStripItem(0)}
				},	
				layout:'fit',
				items:[{
					width:all_width * 20 / 100,
					autoScroll: true,
					collapsible: true,
					id: 'tree-panel-measures-modify',
					enableDrag:true,
					ddGroup: 'customDDGroup',
					split: true,
					xtype: 'treepanel',
					margins: '2 2 2 2',
					useArrows:true,
					rootVisible : false,
					root: {text: '指标分类',draggable: false,id: '-1',isRoot:true},
					loader: new Ext.tree.TreeLoader({ 
							dataUrl: getRootPath()+'/detailReport.report?decorate=no',
							listeners:{beforeload:function(treeLoader, node){
								if(node.attributes.isRoot==true){
									this.baseParams.method = "getRoot";
								}else{
									this.baseParams.method = "getChilds";
								}
								this.baseParams.xmlId = xml_id_;
								this.baseParams.tableName = node.attributes.table;
								this.baseParams.pid = node.attributes.val;
								this.baseParams.level = node.attributes.level;
								this.baseParams.dir = node.attributes.d;
								this.baseParams.time = node.attributes.time;
								this.baseParams.currentTime = Ext.getCmp('currentTime').getRawValue();
						   }}
					}),
					listeners:{
						beforeappend:function(tree,parent,node){
		         	}
					}
				}]	
			},{
				id:'tab1_2_modify',
				title:'指标',
				items:[Ext.getCmp('treeBL_modify_')],
				listeners:{//by mengqingyu modify 隐藏普通模式tab
					activate:function(e){alert();Ext.getCmp('tab_normal_modify').hideTabStripItem(0);Ext.getCmp('tab_normal_modify').setActiveTab(1);}
				}
			}]
		},{
	        	region:'center',
	        	width:320,
	        	height: 500,
	        	margins: '2 2 0 2',
	        	items:new Ext.TabPanel({
	        		activeTab: 0,
	        		id:'tab_normal_modify',
	        		items:[{
	        			title:'普通模式',
	        			style:'padding:15px',
	        			height: 450,
	        			buttons:[{
	        				text:'修改',
	        				handler:function(){
	    	                   	 if(!Ext.getCmp('selColumnName_simple_modify_').validate())
	    	                	 {
	    	                		return;
	    	                	 }
	    	                	 if(!Ext.getCmp('selColumnColumn_simple_modify_').validate())
	    						 {
	    							return;
	    						 }
	    						 var express = '';
	    						 if(Ext.getCmp('selColumnCondition_simple_modify_').getValue().trim()==''){//无条件
	    							 express=Ext.getCmp('selColumnMethod_simple_modify_').getValue()+'($'+Ext.getCmp('selColumnColumn_simple_modify_').code+')';
	    						 }else{
	    							 express=Ext.getCmp('selColumnMethod_simple_modify_').getValue()+'(case when '+Ext.getCmp('selColumnCondition_simple_modify_').getValue().trim()+' then $'+Ext.getCmp('selColumnColumn_simple_modify_').code+' end)';
	    						 }
	    						 //by mengqingyu modify 修改指标内容
	    						 var nodeId = ev.id;
	    						 Ext.getCmp("treeBL").getNodeById(nodeId).remove();//删除指标树
	    						 Ext.getCmp("treeBL_modify_").getNodeById(nodeId).remove();//删除指标树
	    						 var param = {id:ev.id,comColumn:'true',table:"("+Ext.getCmp('selColumnSql_modify_').getValue()+")",time:defaultDate,isSimpleModel:'true',label:Ext.getCmp('selColumnName_simple_modify_').getValue(),customH:'true',express:express,text:Ext.getCmp('selColumnName_simple_modify_').getValue(),selColumnColumnCode:Ext.getCmp('selColumnColumn_simple_modify_'),selColumnColumnName:Ext.getCmp('selColumnColumn_simple_modify_').getValue(),selColumnColumnMethod:Ext.getCmp('selColumnMethod_simple_modify_').getValue(),selColumnConditio:Ext.getCmp('selColumnCondition_simple_modify_').getValue().trim()};
	    						 Ext.getCmp("treeBL").root.appendChild(new Ext.tree.TreeNode(param));
	    						 Ext.getCmp("treeBL_modify_").root.appendChild(new Ext.tree.TreeNode(param));
	    						 ev.outerHTML = "<li id='"+ev.id+"' time='"+Ext.getCmp('selColumnColumn_simple_modify_').time+"' isSimpleModel='true' selColumnColumnCode='"+Ext.getCmp('selColumnColumn_simple_modify_').code+"' selColumnColumnName='"+Ext.getCmp('selColumnColumn_simple_modify_').getValue()+"' selColumnColumnMethod='"+Ext.getCmp('selColumnMethod_simple_modify_').getValue()+"' selColumnCondition=\""+Ext.getCmp('selColumnCondition_simple_modify_').getValue().trim()+"\" oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_simple_modify_').getValue()+"' customH='true' express='"+express+"' class='h'>"+Ext.getCmp('selColumnName_simple_modify_').getValue()+"</li>";
	    						 enable_move();
	    						 Ext.getCmp('customH_win_modify_').hide();
	        				}
	        			}],
	        			buttonAlign:'right',
	        			items:[{
	        				xtype:'fieldset',
	        				collapsible: true,
	        				title: '自定义指标名称',
	        				style:'padding:15px',
	        				height: 80,
	        				defaults:{labelWidth:60,layout:'form',border:false},
	        				items:[{
	            				items:[{
	            					id:'selColumnName_simple_modify_',
	    	        				xtype:'textfield',
	    	        				fieldLabel:'指标名称',
	    	        				border:true,
	    	        				allowBlank:false,
	    	        				blankText:'指标名称不能为空',
	    	        				width:240
	    	        			}]
	            			}]
	        			},{
	        				xtype:'fieldset',
	        				title: '自定义指标配置',
	        				style:'padding:15px',
	        				height: 150,
	        	            collapsible: true,
	        				layout:'table',
	            			frame:true,
	            			layoutConfig: {columns:3},
	            			defaults:{labelWidth:60,layout:'form',border:false},
	            			items:[{
	            				id:'selColumnColumn_simple_div_modify_',
	            				items:[{
	            					id:'selColumnColumn_simple_modify_',
	            					xtype:'textfield',
	            					fieldLabel:'汇总列',
	            					blankText:'汇总列不能为空',
	            					allowBlank:false,
	            					editable:false,
	            					width:100
	            				}]
	            			},{
	            				width:10,
	        					border:false
	            			},{
	            				items:[{
	            					id:'selColumnMethod_simple_modify_',
	            					xtype:'combo',
	            					fieldLabel:'汇总方式',
	            					store:new Ext.data.SimpleStore({
	            						fields: ['name', 'valtext'],
	            						data : [['求和','sum'],['平均值', 'avg'],['总数', 'count'],['最大值', 'max'],['最小值', 'min']]
	            					}),
	            					displayField:'name',
	            					mode: 'local',
	            					value:'sum',
	            					editable:false,
	            					valueField: "valtext",
	            					triggerAction: "all",
	            					width:60
	            				}]
	            			},{
	            				colspan:3,
	            				height:20,
	        					border:false
	            			},{
	            				id:'selColumnCondition_simple_div_modify_',
	            				items:[{
	            					id:'selColumnCondition_simple_modify_',
	            					xtype:'textfield',
	            					fieldLabel:'汇总条件',
	            					width:240
	            				}],
	            				colspan:3
	            			}]
	        			}]
	        		},{
	        			title:'高级模式',
	            		layout: 'table',
	            		height: 450,
	            		border:false,
	            		bodyStyle:'padding:10px 10px 10px 20px',
	            		layoutConfig: {columns:5},
	            		defaults:{frame:false,style:'padding:2px',minWidth: '60',style:{marginBottom: '10px'}},
	            		items:[
	    		         {
	     		    	    id:'selColumnName_modify_',
	     		    	    xtype:'textfield',
	     		    	    width  : 350,
	     		    	    colspan:5,
	     		    	    emptyText:'请输入自定义列名称',
	     		    	    allowBlank:false,
	     		    	    blankText:'自定义列名称不能为空'
	     		         },
	    	        		 {
	    			            xtype: "textarea",
	    			            id: "selColumnSql_modify_",
	    			            width  : 350,
	    			            height : 140,
	    			            enableKeyEvents: true,
	    			            hideLabel:true,
	    			            allowBlank:false,
	    			            blankText:'自定义列表达式不能为空',
	    			            colspan:5,
	    		            style: {
	            			 	marginBottom: '10px',
	    		                imeMode:'disabled'		//屏蔽输入法
	    		            },
	    		            listeners:
	    	            	{
	    	            		'render':function(e)
	    	            		{
	    	            			//屏蔽粘贴和鼠标右键
	    	            			//Ext.get('selColumnSql_').dom.oncontextmenu = function(e){return false;};
	    	            			//Ext.get('selColumnSql_').dom.onpaste = function(e){return false;};
	    	            		}
	    	            		,'keypress':function(e)
	    	            		{//屏蔽键盘按键
	    							//event.keyCode = 0;
	    							//event.returnvalue = false;
	    	            		}
	    	            		
	    	            	}
	    		        }		        		 
	            		 ,{
	    			        	xtype: "button",
	    	                    text: "sum",
	    	                    handler: function(){
	    	                    		//by mengqingyu modify 指标不参与聚合函数计算
	    			             		var node;
	    			            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    			            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    			            		}
	    			            		else{
	    			            			alert("请选择指标分类!");
	    			            			return;
	    			            		}
	    	                    		if(node != null){
	    		                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	    	                    		}else{
	    	                    			alert("请选择指标!");
	    	                    		}
	    	                    }
	    	                }
	    	                ,{
	    			        	xtype: "button",
	    	                    text: "avg",
	    	                    handler: function(){
	    			             		var node;
	    			            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    			            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    			            		}
	    			            		else{
	    			            			alert("请选择指标分类!");
	    			            			return;
	    			            		}
	    	                    		if(node != null){
	    		                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	    	                    		}else{
	    	                    			alert("请选择指标!");
	    	                    		}
	    	                    }
	    	                }
	    	                ,{
	    			        	xtype: "button",
	    	                    text: "count",
	    			                    handler: function(){
	    			             		var node;
	    			            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    			            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    			            		}
	    			            		else{
	    			            			alert("请选择指标分类!");
	    			            			return;
	    			            		}
	    	                    		if(node != null){
	    		                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	    	                    		}else{
	    	                    			alert("请选择指标!");
	    	                    		}
	    	                    }
	    	                }
	    	                ,{
	    			        	xtype: "button",
	    	                    text: "max",
	    	                    handler: function(){
	    		             		var node;
	    		            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    		            		}
	    		            		else{
	    		            			alert("请选择指标分类!");
	    		            			return;
	    		            		}
	                        		if(node != null){
	    	                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	                        		}else{
	                        			alert("请选择指标!");
	                        		}
	    	                    }
	    	                }
	    	                ,{
	    			        	xtype: "button",
	    	                    text: "min",
	    	                    handler: function(){
	    		             		var node;
	    		            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    		            		}
	    		            		else{
	    		            			alert("请选择指标分类!");
	    		            			return;
	    		            		}
	                        		if(node != null){
	    	                    		addquery(this,'selColumnSql_modify_','$'+node.attributes.table+"."+node.attributes.column);
	                        		}else{
	                        			alert("请选择指标!");
	                        		}
	    	                    }
	    	                }
	            		 ,{
	    			        	xtype: "button",
	    	                    text: "c-sum",
	    	                    handler: function(){
	    		             		var node;
	    		            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    		            		}
	    		            		else{
	    		            			alert("请选择指标分类!");
	    		            			return;
	    		            		}
	                        		if(node != null){
	                        			this.text="sum";
	                        			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                        		}else{
	                        			alert("请选择指标!");
	                        		}
	    	                    }
	    	             }
	    		        , {
	    		        	xtype: "button",
	                        text: "7",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	    		        }
	    		        , {
	    		        	xtype: "button",
	                        text: "8",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: "9",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " + ",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	            		,{
	    			        	xtype: "button",
	    	                    text: "c-avg",
	    	                    handler: function(){
	    		             		var node;
	    		            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    		            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    		            		}
	    		            		else{
	    		            			alert("请选择指标分类!");
	    		            			return;
	    		            		}
	                        		if(node != null){
	                        			this.text="avg";
	                        			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                        		}else{
	                        			alert("请选择指标!");
	                        		}
	    	                    }
	    	            }
	                    , {
	    		        	xtype: "button",
	                        text: "4",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	    		        }
	                    ,{
	    		        	xtype: "button",
	                        text: "5",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: "6",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " - ",
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	            		,{
	    		        	xtype: "button",
	                        text: "c-count",
	                        handler: function(){
	    	             		var node;
	    	            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    	            		}
	    	            		else{
	    	            			alert("请选择指标分类!");
	    	            			return;
	    	            		}
	                    		if(node != null){
	                    			this.text="count";
	                    			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                        }
	            		}
	                    ,{
	    		        	xtype: "button",
	                        text: "1",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: "2",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: "3",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " * ",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	            		,{
	    		        	xtype: "button",
	                        text: "c-max",
	                        handler: function(){
	    	             		var node;
	    	            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    	            		}
	    	            		else{
	    	            			alert("请选择指标分类!");
	    	            			return;
	    	            		}
	                    		if(node != null){
	                    			this.text="count";
	                    			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                        }
	            		}
	                    ,{
	    		        	xtype: "button",
	                        text: "0",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: ".",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " % ",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " / ",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	            		,{
	    		        	xtype: "button",
	                        text: "c-min",
	                        handler: function(){
	    	             		var node;
	    	            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    	            		}
	    	            		else{
	    	            			alert("请选择指标分类!");
	    	            			return;
	    	            		}
	                    		if(node != null){
	                    			this.text="min";
	                    			addquery(this,'selColumnSql_modify_','case when '+'$'+node.attributes.table+"."+node.attributes.column+' > 0 then '+'$'+node.attributes.table+"."+node.attributes.column+' end');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                        }
	            		}
	                    ,{
	    		        	xtype: "button",
	                        text: " ( ",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " ) ",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: "\'",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: ",",
	                        style:
	                        {
	                        	marginBottom: '5px'
	                        },
	                        handler: function(){addquery(this,'selColumnSql_modify_');}
	                    }
	            		,{
	    		        	xtype: "button",
	                        text: "select",
	                        handler: function(){
	    	             		var node;
	    	            		if(Ext.getCmp('tabs_modify_').getActiveTab().getId()=='tab1_1_modify'){
	    	            			node = Ext.getCmp('tree-panel-measures-modify').getSelectionModel().getSelectedNode();
	    	            		}
	    	            		else{
	    	            			alert("请选择指标分类!");
	    	            			return;
	    	            		}
	                    		if(node != null){
	                    			this.text='$'+node.attributes.table+"."+node.attributes.column;
	                    			addquery(this,'selColumnSql_modify_');
	                    		}else{
	                    			alert("请选择指标!");
	                    		}
	                        }
	            		}
	                    ,{
	    		        	xtype: "button",
	                        text: " 清除 ",
	                        handler: function(){
	                        		Ext.getCmp('selColumnSql_modify_').setValue() == "";
	    								}
	                    }
	                    ,{
	    		        	xtype: "button",
	                        text: " 修改 ",
	                        handler: function(){
	    	                	 if(!Ext.getCmp('selColumnName_modify_').validate())
	    	                	 {
	    	                		return;
	    	                	 }
	    	                	 if(!Ext.getCmp('selColumnSql_modify_').validate())
	    						 {
	    							return;
	    						 }
	    						 //by mengqingyu modify 修改指标内容
	    						 var nodeId = ev.id;
	    						 Ext.getCmp("treeBL").getNodeById(nodeId).remove();//删除指标树
	    						 Ext.getCmp("treeBL_modify_").getNodeById(nodeId).remove();//删除指标树
	    						 var param = {id:ev.id,comColumn:'true',table:"("+Ext.getCmp('selColumnSql_modify_').getValue()+")",time:defaultDate,isAdvanceModel:'true',label:Ext.getCmp('selColumnName_modify_').getValue(),customH:'true',express:Ext.getCmp('selColumnSql_modify_').getValue(),text:Ext.getCmp('selColumnName_modify_').getValue()};
	    						 Ext.getCmp("treeBL").root.appendChild(new Ext.tree.TreeNode(param));
	    						 Ext.getCmp("treeBL_modify_").root.appendChild(new Ext.tree.TreeNode(param));
	    						 enable_move();
	    						 ev.outerHTML = "<li id='"+ev.id+"' time='"+Ext.getCmp('selColumnColumn_simple_modify_').time+"' isAdvanceModel='true' oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_modify_').getValue()+"' customH='true' express='"+Ext.getCmp('selColumnSql_modify_').getValue()+"' class='h'>"+Ext.getCmp('selColumnName_modify_').getValue()+"</li>";
	    						 alert("<li id='"+ev.id+"' time='"+Ext.getCmp('selColumnColumn_simple_modify_').time+"' isAdvanceModel='true' oncontextmenu='showmenu(this)' label='"+Ext.getCmp('selColumnName_modify_').getValue()+"' customH='true' express='"+Ext.getCmp('selColumnSql_modify_').getValue()+"' class='h'>"+Ext.getCmp('selColumnName_modify_').getValue()+"</li>");
	    						 Ext.getCmp('customH_win_modify_').hide();
	                        }
	                    }
	            		]
	        	}]})
	        }
	   		]
	 	});//Ext.Window
	Ext.getCmp('customH_win_modify_').show();
}
	
